package com.app.stick.notice.controller;

import java.util.List;

import com.github.pagehelper.PageInfo;
import io.swagger.annotations.*;
import org.springframework.security.access.prepost.PreAuthorize;
import javax.annotation.Resource;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.app.common.annotation.Log;
import com.app.common.core.controller.BaseController;
import com.app.common.core.domain.ApiResult;
import com.app.common.enums.BusinessType;
import com.app.stick.notice.domain.BizMessageNotice;
import com.app.stick.notice.service.IBizMessageNoticeService;

/**
 * 消息通知Controller
 *
 * @author app
 * @date 2023-12-21
 */
@Api(value = "消息通知", tags = {"WEB-消息通知接口"})
@RestController
@RequestMapping("/notice/info")
public class BizMessageNoticeController extends BaseController
{
    @Resource
    private IBizMessageNoticeService bizMessageNoticeService;

    /**
     * 查询消息通知列表
     */
    @ApiOperation("查询消息通知列表")
    @GetMapping("/list")
    public ApiResult<List<BizMessageNotice>> list(BizMessageNotice bizMessageNotice)
    {
        startPage();
        List<BizMessageNotice> list = bizMessageNoticeService.selectBizMessageNoticeList(bizMessageNotice);
        return ApiResult.page(list, new PageInfo(list).getTotal());
    }

    /**
     * 获取消息通知详细信息
     */
    @ApiOperation("获取消息通知详细信息")
    @ApiImplicitParam(name = "msgId", value = "消息通知ID", dataType = "String", dataTypeClass = String.class, required = true)
    @GetMapping(value = "/getInfo/{msgId}")
    public ApiResult<BizMessageNotice> getInfo(@PathVariable("msgId") String msgId)
    {
        return ApiResult.ok(bizMessageNoticeService.selectBizMessageNoticeByMsgId(msgId));
    }

    /**
     * 删除消息通知
     */
    @ApiOperation("删除消息通知(notice:info:remove)")
    @ApiImplicitParam(name = "msgId", value = "消息通知ID", dataType = "String", dataTypeClass = String.class, required = true)
    @PreAuthorize("@ss.hasPermi('notice:info:remove')")
    @Log(title = "消息通知", businessType = BusinessType.DELETE)
    @DeleteMapping("/remove/{msgId}")
    public ApiResult<Integer> remove(@PathVariable("msgId") String msgId)
    {
        return ApiResult.toR(bizMessageNoticeService.deleteBizMessageNoticeByMsgId(msgId));
    }
}
